unit uCadHorarios;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, CheckLst, uFraHorario, ComCtrls;

type
  TfrmCadHorarios = class(TForm)
    clbDias: TCheckListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label9: TLabel;
    btnSearchDoutor: TSpeedButton;
    SpeedButton2: TSpeedButton;
    DateTimePicker3: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    btnSalvar: TBitBtn;
    fraHorario1: TfraHorario;
    SpeedButton1: TSpeedButton;
    procedure clbDiasClickCheck(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    OldSemanaChecked: boolean;
    function SemanaChecked: boolean;
    procedure SetSemanaChecked(check:boolean);
  public
    property Semana: boolean read SemanaChecked write SetSemanaChecked;
  end;

var
  frmCadHorarios: TfrmCadHorarios;

implementation

{$R *.dfm}

procedure TfrmCadHorarios.clbDiasClickCheck(Sender: TObject);
begin
  if OldSemanaChecked = clbDias.Checked[0] then
    SetSemanaChecked(clbDias.Checked[0]);
    //Semana := clbDias.Checked[0];
end;

procedure TfrmCadHorarios.FormShow(Sender: TObject);
begin
  OldSemanaChecked := false;
end;

function TfrmCadHorarios.SemanaChecked: boolean;
var
  item: Integer;
begin
  result:=true;
  for item := 1 to 5 do
    if not clbDias.Checked[item] then
    begin
      result:= false;
      Break;
    end;
end;

procedure TfrmCadHorarios.SetSemanaChecked(check: boolean);
var
  item: Integer;
begin
  OldSemanaChecked:= check;
  for item := 0 to 5 do
    clbDias.Checked[item] := check;
end;

end.
